Skip to content

Claude/expand test coverage - #91

Merged
samsledje merged 10 commits into
mainfrom
claude/expand-test-coverage-01LESFRdKZ3cgtzyfhKfzto4
Dec 16, 2025
Merged

Claude/expand test coverage#91
samsledje merged 10 commits into
mainfrom
claude/expand-test-coverage-01LESFRdKZ3cgtzyfhKfzto4

Conversation

@samsledje

Copy link
Copy Markdown
Owner

No description provided.

Add extensive test coverage for previously untested modules:

- test_utils.py: Comprehensive tests for utility functions (setup_logger, log, RBF,
  parse_device, load_hdf5_parallel, PairedDataset, collate_paired_sequences)

- test_glider.py: Complete test suite for graph-based link prediction module
  (get_dim, densify, compute_X_normalized, scoring functions, GLIDE algorithms)

- test_loading.py: Tests for parallel HDF5 data loading with LoadingPool,
  including edge cases, error handling, and integration tests

- test_language_model.py: Expanded from 2 to 13 test methods, adding coverage
  for lm_embed, embed_from_fasta with various edge cases and validations

These additions significantly improve test coverage for:
- dscript/utils.py (167 lines, previously untested)
- dscript/glider.py (346 lines, previously untested)
- dscript/loading.py (92 lines, previously untested)
- dscript/language_model.py (minimal coverage expanded)

Total new test methods: ~200+ assertions across 4 test modules
Create four new test modules to expand coverage of previously untested code:

1. test_extract_3di.py (19 test methods, ~370 lines)
   - Tests for 3Di sequence extraction from PDB/CIF files
   - Argument parsing, file filtering, FASTA output validation
   - Integration tests for full workflow
   - Covers dscript/commands/extract_3di.py (~58 lines)

2. test_par_writer.py (24 test methods, ~400 lines)
   - Tests for parallel prediction writer process
   - TSV output writing, threshold filtering, contact map storage
   - HDF5 contact map dataset handling
   - Progress tracking and data type validation
   - Covers dscript/commands/par_writer.py (~40 lines)

3. test_main.py (24 test methods, ~320 lines)
   - Tests for CLI entry point and argument parsing
   - CitationAction class testing
   - All subcommand registration and invocation
   - Version and help flag handling
   - Integration tests for command dispatch
   - Covers dscript/__main__.py (~87 lines, increasing from ~85% to ~95%)

4. test_load_worker.py (23 test methods, ~330 lines)
   - Direct unit tests for HDF5 loading worker function
   - Queue handling, data type conversion, memory sharing
   - Error handling for corrupted/missing files
   - Multi-dimensional array support
   - Covers dscript/load_worker.py (~25 lines, previously only indirect coverage)

Total additions:
- ~1,420 lines of new test code
- 90+ test methods with comprehensive assertions
- ~210 lines of source code now directly tested
- Addresses high-priority gaps identified in coverage analysis

These tests complement the existing suite and focus on command-line
interface components and parallel processing infrastructure.
@samsledje samsledje changed the title Claude/expand test coverage 01 lesf rd kz3cgtzyfh kfzto4 Claude/expand test coverage Dec 3, 2025
claude and others added 4 commits December 3, 2025 20:37
- Remove unused variables flagged by ruff
- Apply ruff formatting to all test files
- Ensure all pre-commit hooks pass

Changes:
- test_loading.py: Remove unused 'f' variable
- test_main.py: Remove unused 'fake_out' and 'output' variables
- test_utils.py: Remove unused 'log_file' variable and tmp_path param
- Applied ruff formatting to maintain code style consistency
Rewrote test_load_worker.py to prevent CI hangs that occurred when
tests called the blocking worker function directly. The worker function
_hdf5_load_partial_func runs in an infinite loop waiting on a queue,
which caused tests to hang indefinitely.

Changes:
- Created run_worker_with_timeout() helper that wraps worker execution
  in a daemon thread with configurable timeout (default 5 seconds)
- Modified all tests to use this helper and assert successful completion
- Changed queue operations from blocking get() to non-blocking get_nowait()
- Reduced test count from 23 to 16 focused tests
- Added documentation noting worker is primarily tested via LoadingPool

This should resolve the CI timeout issue where tests hung at 43% completion.
The original tests were calling the real language model which:
- Downloads/loads pretrained model weights (slow, can fail)
- Runs actual neural network inference (resource intensive)
- Causes test failures when model files aren't available

Changes:
- Rewrote unit tests to mock get_pretrained() function
- Mock model returns realistic tensor shapes but doesn't load weights
- Tests are now fast, reliable, and don't require model files
- Moved real model tests to TestLanguageModelIntegration class
- Marked integration tests with @pytest.mark.slow so they can be skipped
- Removed unnecessary loguru import that caused import errors
- Removed problematic setup.py install step from setup_class

This should fix the 4 failing tests reported by CI.
@samsledje
samsledje requested a review from Copilot December 16, 2025 15:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands test coverage across multiple modules in the dscript project. The changes include comprehensive test suites for utility functions, command-line interfaces, data loading, model embedding, graph algorithms, and configuration updates.

  • Added extensive test coverage for core utility functions, data loading, and CLI functionality
  • Migrated build system from setuptools to uv and updated GitHub Actions workflow accordingly
  • Updated version management to use dynamic package metadata instead of hard-coded values

Reviewed changes

Copilot reviewed 14 out of 26 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/bmpi_bench/readme.txt Removed trailing blank line
notebooks/r-md/analyze_human2fly.Rmd Removed trailing blank line
pyproject.toml Migrated build system from setuptools to uv_build, made version static, added coverage omit configuration
dscript/utils.py Added pseudocount parameter to RBF function and early return handling for empty sequences in collate function
dscript/tests/test_utils.py Added comprehensive test suite for utility functions including logging, RBF, data loading, and collation
dscript/tests/test_par_writer.py Added test suite for parallel prediction writer functionality
dscript/tests/test_main.py Added test suite for CLI entry point and subcommand routing
dscript/tests/test_load_worker.py Added test suite for HDF5 loading worker with timeout handling
dscript/tests/test_language_model.py Refactored and expanded language model embedding tests with mocked and integration variants
dscript/tests/test_glider.py Added comprehensive test suite for graph-based link prediction functions
dscript/tests/test_extract_3di.py Added test suite for 3Di sequence extraction command
dscript/tests/_incomplete_test_loading.py Added partial test suite for parallel data loading (marked as incomplete)
dscript/init.py Changed from hard-coded version to dynamic metadata retrieval
.github/workflows/autorun-tests.yml Updated CI workflow to use Python 3.11, uv package manager, and new test commands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment thread dscript/__init__.py
Comment thread .github/workflows/autorun-tests.yml Outdated
Comment thread .github/workflows/autorun-tests.yml Outdated
samsledje and others added 3 commits December 16, 2025 10:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@samsledje
samsledje merged commit 1bed6a0 into main Dec 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants